package helloworld;

import com.lmax.disruptor.WorkHandler;
import lombok.Data;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author ChenJunhong
 * @date 2018/12/19
 * Description:
 */
@Data
public class Comsumer implements WorkHandler<Order> {

    /**
     * 消费者ID
     */
    private String comsumerId;

    /**
     * 记录消费的次数
     */
    public static final AtomicInteger count = new AtomicInteger(0);


    public Comsumer(String comsumerId) {
        this.comsumerId = comsumerId;
    }

    @Override
    public void onEvent(Order event) throws Exception {
        System.out.println("消费者："+comsumerId+"消费了数据，ID="+event.getId()+"Name="+event.getName());
        count.incrementAndGet();
    }
}
